home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 248 / 248.d81 / t.db+ doc 3 < prev    next >
Encoding:
Text File  |  2004-01-01  |  13.6 KB  |  542 lines

  1. u
  2.             DOTBASIC PLUS
  3.                Part III
  4.      by Dave Moorman & Lee Novak
  5.  
  6.  
  7.     Never again must you fight for
  8. string space in your text adventures
  9. and other programs. With the following
  10. commands, you can put your lines of
  11. text in a Edstar file (Edstar is our
  12. nifty text editor that produces 38-
  13. column lines of text), use .BL0 to
  14. bload it into memory (under ROM), the
  15. use RACK (.RK) to turn the text into a
  16. virtual string array. RACK INDEX (.RI)
  17. will put any line into W$ for use in
  18. your program. Here is a simple
  19. example:
  20.  
  21.  100 .BL0,"T.DISKOVER",D,40960
  22.  110 .RK,40960
  23.  120 FOR X = 1 TO N%
  24.  130 .RI,X
  25.  140 PRINT W$
  26.  150 NEXT
  27.  
  28.  
  29.   RACK EDSTAR FILE
  30.   ----------------
  31.     Include: .RK
  32.   .RK,LOCATION
  33.  
  34.     This routine takes an EDSTAR file
  35. (terminated by a zero) and "racks it
  36. up". A table of pointers is created
  37. right after the zero at the end of the
  38. text, enabling you to use .RI or .PRI
  39. to grab or print individual lines of
  40. the file.
  41.  
  42.     The file can be located anywhere
  43. in memory, even under I/O. Racking
  44. needs 3 bytes per line at the end of
  45. the file for its pointers. The total
  46. number of items is returned in N%.
  47.  
  48.  
  49.   INDEX ITEM
  50.   ----------
  51.     Include: .RI
  52.   .RI,INDEX#
  53.  
  54.     Once you've racked up an EDSTAR
  55. file, you can index it. The indexed
  56. item is returned in W$. F$ is also set
  57. by indexing, and will always return a
  58. null unless you happen to be looking
  59. at a directory, in which case it
  60. contains the entry's filename.
  61.  
  62.  
  63.   PRINT ITEM
  64.   ----------
  65.     Include: .PRI
  66.   .PRI,X,Y,INDEX#
  67.  
  68.     This routine indexes an item and
  69. prints it anywhere on the screen. The
  70. string is NOT returned in W$ or F$.
  71.  
  72.  
  73.   PRINT FILENAME
  74.   ----------
  75.     Include: .PRFILE
  76.   .PRFILE,X,Y,INDEX#
  77.  
  78.     If you've used GET DIRECTORY and
  79. have racked up the resulting text, you
  80. can immediately print the filenames.
  81.  
  82.  
  83.   DEFINE REGION TEXT
  84.   ------------------
  85.     Include: .DRTEXT
  86.   .DRTEXT,NUMBER,"STATIC STRING"
  87.  
  88.     The concept of "region text" for
  89. LOADSTAR programs is credited to both
  90. Jeff Jones and myself. CASH FLOWER (LS
  91. #161) and QUICKSMITH (LS #164) both
  92. used the concept, and it's interesting
  93. to note that neither of us knew what
  94. the other was up to.
  95.  
  96.     "Region text" is when the user
  97. moves the mouse pointer around the
  98. screen, and a message bar at the
  99. bottom of the screen informs the user
  100. of what will happen if he or she
  101. clicks on that particular area. These
  102. strings don't have to be associated
  103. with regions - it's just likely that
  104. this will be their most common use.
  105.  
  106.    Related Variables:     (& defaults)
  107.  
  108.   MV+20  Region Text Zone (LB)     (0)
  109.   MV+21  Region Text Zone (HB)     (4)
  110.   MV+22  Region Text Color / Flags (1)
  111.   MV+23  Region Text Row          (24)
  112.  
  113.     Strings defined as region text
  114. must NOT be made by combining smaller
  115. strings. The string's POINTER will be
  116. stored in its proper slot in the
  117. Region Text Zone. Be sure this zone is
  118. safe from BASIC and other data We
  119. suggest the area in pages 46-55. The
  120. Zone will never exceed 3 pages.
  121.  
  122.     All region text will be printed in
  123. MV+22's color. Add 128 to MV+22 for
  124. REVERSE printing. (Adding 64 changes
  125. the way the pointers are stored and is
  126. most useful from ML.)
  127.  
  128.     Add 32 to MV+22 and all your
  129. region text will be CENTERED. Add 16
  130. instead, and each string will be
  131. printed after a forced leading SPACE.
  132.  
  133.  
  134.   EDSTAR TO REGION TEXT
  135.   ---------------------
  136.     Include: .EDRTEXT
  137.   .EDRTEXT,LOCATION
  138.  
  139.     This command defines ALL region
  140. text with a single command! It takes
  141. an EDSTAR file (terminated by 0),
  142. racks it up, and POKEs MV+24 and
  143. MV+25. The number of lines in the file
  144. is returned in N%.
  145.  
  146.     Keep in mind that the FIRST line
  147. of the EDSTAR file will be referenced
  148. by number zero. You can have as many
  149. lines as you want.
  150.  
  151.  
  152.   PRINT REGION TEXT
  153.   -----------------
  154.     Include: .PRTEXT
  155.   .PRTEXT,INDEX
  156.  
  157.     This prints region text on the
  158. line specified in MV+23. It fills up
  159. the unused part of the line with
  160. spaces, so you don't have to worry
  161. about erasing the old text before
  162. printing over it. The string will be
  163. printed as specified in MV+22, above.
  164. Usually the "index" will be RG%, but
  165. it doesn't have to be.
  166.  
  167.     Here is a simple example:
  168.  
  169.  100 .BL0,"TEXTFILE",D,40960
  170.  110 .EDRTEXT,40960
  171.  200 .DO:.MA
  172.  210 .PRTEXT,RG%
  173.  220 .UN CR%
  174.  
  175.  
  176.   PRINT MESSAGE
  177.   -------------
  178.     Include: .MSG
  179.   .MSG,COLOR,STRING
  180.  
  181.     This command prints your string
  182. just like region text. You provide the
  183. color, and MV+22 specifies the reverse
  184. state, centering, or the leading
  185. space. This command is useful for
  186. special prompts and messages. The plus
  187. "+" can be used to concatenate strings
  188. printed by this routine.
  189.  
  190.  
  191.   GET DIRECTORY
  192.   -------------
  193.     Include: .DIR
  194.   .DIR,"$:*",D,LOC,#FILENAMES
  195.  
  196.     This will read the disk directory
  197. from device D. The directory can be
  198. placed anywhere, even under I/O. DB+
  199. converts the directory to an EDSTAR
  200. file as it is brought in. This allows
  201. SCROLLING MENU to use the information
  202. as a file requestor.
  203.  
  204.     Normally you would use "$:*" to
  205. get all the disk's filenames. You can
  206. replace "$:*" with any search pattern
  207. you want, up to 16 characters long.
  208. For example, using "$:b.*,p.*" on a
  209. LOADSTAR disk (using a real C-64 or
  210. True Drive in VICE) would bring in the
  211. names of all the boot and text files.
  212.  
  213.     E$ will return the error message.
  214. T$ will contain the disk's name within
  215. quotes, and B$ will contain the
  216. "blocks free" message. Use VAL(B$) to
  217. extract the number of blocks free on
  218. the disk. N% returns the number of
  219. filenames loaded.
  220.  
  221.     If there was an error during the
  222. directory getting, T$ and B$ will
  223. return strings full of spaces, and E$
  224. will tell about the error. The one
  225. thing your program should do before
  226. disk access is check if the drive is
  227. actually online, like this:
  228.  
  229.    1000 close2:open2,dv,2:close2
  230.    1010 if st=-128 then...
  231.    1020 ...continue
  232.  
  233.     Line 1010 would go and deal with a
  234. "device not present" situation. If all
  235. is well, line 1020 executes and disk
  236. access occurs.
  237.  
  238.     GET DIRECTORY has been greatly
  239. improved with the addition of one more
  240. parameter: how many filenames you have
  241. room to hold. This number should be
  242. calculated as:
  243.  
  244.    # files = INT((bufferspace-1)/32)
  245.  
  246.      For example, if your buffer was
  247. from 49152 to 53248, you could fit
  248. INT((4096-1)/32) = 127 names there.
  249. This formula takes into account the
  250. zero cap and the three bytes per line
  251. that the racking process needs.
  252.  
  253.     If the buffer space is filled up
  254. before all the filenames are loaded,
  255. B$ will return "more files on disk".
  256. If you don't care about buffer space,
  257. use 0 for the number of filenames.
  258.  
  259.     A good place to put your directory
  260. information is in pages 224+. You
  261. easily put 250 filenames in this area
  262. under ROM.
  263.  
  264.  
  265.   SCROLLING MENU
  266.   --------------
  267.     Include: .SCMENU
  268.   .SCMENU,X,Y,W,H,B,I,UN,HI,LOC,T$,B$
  269.  
  270.     For this command to work, you must
  271. have an EDSTAR file in memory, and it
  272. must end with a zero byte OR use .DIR
  273. to get the directory.
  274.  
  275.     The X,Y,W,H parameters set the
  276. area the menu will occupy. H must be
  277. at least 7 characters tall and W 11
  278. wide. B is the color of the menu box.
  279. The unhighlighted items of the menu
  280. are color UN. HI is the highlight bar
  281. color. If you don't want the text to
  282. reverse or un-reverse as the bar
  283. moves, add 128 to HI.
  284.  
  285.     I is the color of the four words
  286. in the corners of the menu: HOME, UP,
  287. DOWN, and QUIT. Left-click on UP or
  288. DOWN to scroll the text. Right-click
  289. on them and the list jumps a page at a
  290. time. The user can use the CRSR keys
  291. to scroll or page through the text as
  292. well.
  293.  
  294.     Clicking on HOME will bring the
  295. list to the top. Pressing the HOME key
  296. will bring the highlight bar to the
  297. top of the page, and the next press
  298. brings the list to the top.
  299.  
  300.     Click on an item or press RETURN
  301. to select it. The entire item is
  302. returned in W$. F$ will return a null
  303. unless this is a file requestor - in
  304. which case it contains the filename.
  305. SL% returns the selection number.
  306.  
  307.     Clicking on QUIT, pressing Q, or
  308. pressing the Global Escape key will
  309. return zero in SL% and nulls in W$ and
  310. F$.
  311.  
  312.     LOC is the location of the EDSTAR
  313. file, which can be anywhere in memory.
  314. The file will be "racked up" before
  315. use, which can take up to a second
  316. (gasp!) on 1 MHz machines. For already
  317. racked data, put 0 in LOC.
  318.  
  319.     T$ is printed at the menu's top,
  320. in reverse, between HOME and UP. B$ is
  321. printed at the bottom, between QUIT
  322. and DOWN. You needn't use the actual
  323. variables T$ and B$, but if this is
  324. going to be a file requestor, it's
  325. perfect. The user gets to see the disk
  326. name and blocks free without any extra
  327. effort from you.
  328.  
  329.     There is no way to customize the
  330. scrolling menu. Auto-caging and
  331. point-to-first are mandatory.
  332.  
  333.     Set W to 255 and the proper width
  334. for a file requestor will be assigned,
  335. but that's it. DB+ knows what filename
  336. info looks like and will set F$
  337. properly when it finds a filename -
  338. regardless of width.
  339.  
  340.     NOTE: Using the SCROLLING MENU
  341. with a location in LOC changes what
  342. the RACK INDEX routine is cued up to
  343. read and removes any sorting.
  344.  
  345.  
  346.   CHARACTER SWAP
  347.   --------------
  348.     Include: .CHRSWP
  349.   .CHRSWP,SEEK,REPLACE,COLOR
  350.  
  351.     This small routine scans the
  352. screen for a specific screen code, and
  353. replaces it with the given screen
  354. code, with the given color. A color of
  355. 128 causes only the characters to be
  356. changed, not their colors.
  357.  
  358.  
  359.   COLOR SWAP
  360.   ----------
  361.     Include: .COLSWP
  362.   .COLSWP,SEEK,REPLACE
  363.  
  364.     This routine finds all instances
  365. of a specific color and replaces them
  366. with the given color. Screen memory is
  367. not affected.
  368.  
  369.  
  370.   MORE ABOUT INDEXING
  371.   -------------------
  372.  
  373.     When a file is RACKed up by
  374. yourself or a scrolling menu, MV+24/25
  375. reveal the location of the text's
  376. newly generated pointers. The number
  377. of items in the current INDEXable file
  378. is at MV+26/27. These two variables
  379. are at the disposal of the advanced
  380. programmer.
  381.  
  382.     By preserving and later restoring
  383. MV+24-27, it is possible have two or
  384. more INDEXable files in memory at
  385. once, without having to RACK them
  386. (taking almost a second) just so you
  387. can switch between them.
  388.  
  389.     RACKing also would wipe out all
  390. the "selected" flags stored as bit 7
  391. of each item's LENGTH value (by
  392. .MSMENU). You may want to preseve
  393. MV+24-27 before calling another
  394. scrolling menu so you do not lose
  395. these flags. POKE the saved values
  396. back into MV+24-27 when it's time to
  397. INDEX SELECTED ITEMs.
  398.  
  399.     Yes sir. We have multi-selectable
  400. scrolling menus now! Hang on!
  401.  
  402.      X+128 enables a powerful new
  403. feature. If you do not like the
  404. generic look of the scrolling menu,
  405. you can now do something about it!
  406.  
  407.     Several things DON'T happen when
  408. x+128 is used. The bx,ic,t$, and b$
  409. parameters are IGNORED. The scrolling
  410. menu is NOT drawn. The CAGE remains
  411. unchanged. The X,Y,W,H parameters now
  412. represent the area for the ACTUAL
  413. scrolling text alone.
  414.  
  415.      "Manual Icons" means just that.
  416. DB+ is trusting YOU to create, label,
  417. and enable (as regions) the icons for
  418. your scrolling menu. They can be any
  419. size and at any location.
  420.  
  421.     Since you may not always label the
  422. EXIT icon as "Quit", MV+16 exists so
  423. you can assign an appropriate key to
  424. the exit function. The CRSR keys still
  425. scroll and page, and HOME still goes
  426. home. ESCAPE cancels, just like EXIT
  427. (in the regular scrolling menu).
  428.  
  429.     MULTI-SELECT SCROLL MENUs need two
  430. additional parameters, S and W.
  431.  
  432. .MSMENU,X,Y,W,H,bx,ic,u,h,s,w,l,t$,b$
  433.  
  434.     The confusing letters are mostly
  435. COLORs and read like this:
  436.  
  437.     Box
  438.     Icons
  439.     Un-highlight
  440.     Highlight
  441.     Selected
  442.     (selected) With bar
  443.     Location
  444.  
  445.     It's always easy to spot the
  446. selected items, even when they are
  447. under the highlight bar. Which of the
  448. u,h,s,w items are REVERSED is set from
  449. bits 3-0 to MV+15. By default, the
  450. highlight bar and all selected items
  451. are reversed. Each reverse bit can be
  452. temporarily disobeyed by adding 128 to
  453. the u,h,s,w parameters.
  454.  
  455.     Selecting items is as easy as
  456. hitting RETURN or clicking on them.
  457. The item is toggled and the mouse and
  458. highlight bar are moved down to the
  459. next item, scrolling when necessary -
  460. even when selecting with the mouse!
  461.  
  462.     The additional keys A, N, and T
  463. function within multi-select menus to
  464. select ALL, NONE, and to TOGGLE ALL
  465. items (respectively). The mouse user
  466. cannot access these special features
  467. unless YOU enable manual icons!
  468.  
  469.     Exiting a multi-select menu is the
  470. confusing part. If you press the EXIT
  471. key (MV+16), SL% will return the
  472. number of items selected. If ESCAPE is
  473. pressed, the menu is cancelled and
  474. zero is returned in SL%. The selected
  475. items still exist, and still can be
  476. indexed, but you are just told that
  477. there weren't any selected items.
  478.  
  479.     If you are using manual icons, the
  480. mouse usually can move anywhere on the
  481. screen. Nothing happens if the user
  482. clicks outside the menu. Even clicking
  483. on an active region has no effect IF
  484. the region number isn't one to which
  485. we have assigned a function.
  486.  
  487.     Here are the REGION NUMBERS and
  488. the functions they would have for a
  489. regular scrolling menu:
  490.  
  491.      1. home
  492.      2. scroll up
  493.      3. scroll down
  494.      4. exit
  495.      5. page up
  496.      6. page down
  497.  
  498.      Regions 5 and 6 aren't
  499. necessary, so don't feel obligated to
  500. use them. Nothing bad will happen if
  501. you don't have 6 active regions.
  502. Right-clicking on regions 2 and 3
  503. also PAGE, too.
  504.  
  505.     MULTI-SELECT SCROLL MENUs will
  506. obey up to four extra regions, if you
  507. take the time to define them.
  508.  
  509.      7. select all
  510.      8. select none
  511.      9. toggle all
  512.     10. cancel
  513.  
  514.     Pressing EXIT or clicking on
  515. region 4 will return the number of
  516. selected items in SL%. Region 10
  517. behaves just like ESCAPE, returning a
  518. grand total of zero selected items.
  519.  
  520.     Remember: When regions overlap,
  521. the higher number has priority. So, if
  522. you don't want regions 5 and 6 in your
  523. multi-select menu, just be sure to
  524. define regions 7 and 8 so they
  525. perfectly overlap the previous two!
  526.  
  527.     However, joystick users with a
  528. repeating fire button may appreciate
  529. regions 5 and 6. No matter what you
  530. decide, be sure to include regions
  531. 1-4: the same ones that are present
  532. using the generic "standard" icons.
  533.  
  534.  
  535.  STAY TUNED!
  536.  -----------
  537.  
  538.     There's more fun in Part IV!
  539.  
  540.  DMM/LN
  541.  
  542.  
  543.